<%--
  Created by IntelliJ IDEA.
  User: Root404
  Date: 2023/10/9
  Time: 15:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<input type="text" id="name" ><span style="color: red"></span>
<input type="text" id="id1"  >
<ul>

</ul>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js">
</script>
<script>
    $("#name").blur(function () {
        $("span").html(" ");
        var name=$(this).val();
       // alert(name);
        $.getJSON("${pageContext.request.contextPath}/registerbyname?title="+name,
        function (data) {
                if(data=="y"){
                    $("span").html("对不起，不能注册");
                }else{
                    $("span").html("恭喜可以注册");
                }
        })
    });
    //根据id泛型查询
    $("#id1").blur(function () {
        $("ul").html(" ");
        var categoryId=$(this).val();
        // alert(name);
        $.getJSON("${pageContext.request.contextPath}/findEntryBycategoryId?categoryId="+categoryId,
            function (data) {
                $.each(data,function () {//1 2 3
                    var li="<li>"+this.id+this.title+this.createdate+"</li>";
                    $("ul").append(li);
                })
            })
    });
</script>
</body>
</html>
